﻿
@{
    Layout = null;
}

<style>
    #dv_opedit {
        position: fixed;
        top: 19%;
        right: 10px;
    }

    .dv-left {
        width: 300px;
        float: left;
    }

    .dv-left-tb {
        /*overflow-y: auto;*/
        border-radius: 5px;
        background: #ffffff;
        border: 5px double #a6e6a5;
    }

    #sscz {
        float: left;
        background-color: #a6e6a5;
        height: 100px;
        padding: 10px;
        color: #645a5a;
        border-radius:5px;
    }
</style>


<div id="dv_opedit">
    <a class="btn  " id="sscz">手<br />术<br />管<br />理<br /><span class="glyphicon glyphicon-edit"></span></a>
    <div class="dv-left">
        <div class="dv-left-tb" id="tb_opedit" style="padding-top:10px;height:365px;">
            <div><input type="hidden" id="op_rowid" name="op_rowid" /></div>
            <table class="form" style="width:95%;">
                <tr>
                    <th class="formTitle "><span class="required">*</span>手术及操作：</th>
                    <td class="formValue">
                        <input id="op_ssdm" name="op_ssdm" class="form-control required" attr-ssdm="" attr-ssjb="" autocomplete="off" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle "><span class="required">*</span>手术及操作日期：</th>
                    <td class="formValue">
                        <input id="op_ssrq" type="text" class="form-control input-wdatepicker formClearIgnore required" value="" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd H:00:00',maxDate:'#F{\'%y-%M-%d\'}'})" />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle "><span class="required">*</span>主刀医生：</th>
                    <td class="formValue">
                        <input id="op_zdys" name="op_zdys" class="form-control"  />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle ">I助：</th>
                    <td class="formValue">
                        <input id="op_sszl1" name="op_sszl1" class="form-control "  />

                    </td>
                </tr>
                <tr>
                    <th class="formTitle ">II助：</th>
                    <td class="formValue">
                        <input id="op_sszl2" name="op_sszl2" class="form-control"  />
                    </td>
                </tr>
                <tr>
                    <th class="formTitle ">切口愈合等级：</th>
                    <td class="formValue">
                        <select id="op_yhdj" name="op_yhdj" class="form-control ">
                            <option value="">请选择</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <th class="formTitle ">切口愈合类别：</th>
                    <td class="formValue">
                        <select id="op_yhlb" name="op_yhlb" class="form-control ">
                            <option value="">请选择</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <th class="formTitle ">麻醉方式：</th>
                    <td class="formValue">
                        <select id="op_mzfs" name="op_mzfs" class="form-control ">
                            <option>请选择</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <th class="formTitle ">麻醉医生：</th>
                    <td class="formValue">
                        <input id="op_mzys" name="op_mzys" class="form-control " />
                        @*<input id="op_sszl2" name="op_sszl2" class="form-control" />*@

                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <input id="btn_submit_op" type="button" class="btn btn-default" value="保存" style="width:50px;background-color:#9cf7cc;float:right;margin-right:10px;" />
                        <input id="btn_del_op" type="button" class="btn btn-default" value="删除" style="width:50px;background-color:#9cf7cc;float:right;margin-right:10px;" />
                        <input id="btn_reset_op" type="button" class="btn btn-default" value="重置" style="width:50px;background-color:#9cf7cc;float:right;margin-right:10px;" />
                    </td>
                </tr>
            </table>
        </div>
    </div>
</div>



<script type="text/javascript">
    var opdata = {};
    function getopdata() {
        opdata = {
            BAH: $("#BAH").val(),
            ZYH: $("#ZYH").val(),
            SSJCZBM: $("#op_ssdm").attr("attr-ssdm"),
            SSJCZRQ: $("#op_ssrq").val(),
            SSJB: $("#op_ssdm").attr("attr-ssjb"),
            SSJCZMC: $("#op_ssdm").val(),
            SZ: $("#op_zdys").attr("data-StaffGh"),
            SZMC: $("#op_zdys").val(),
            YZ: $("#op_sszl1").attr("data-StaffGh"),
            YZMC: $("#op_sszl1").val(),
            EZ: $("#op_sszl2").attr("data-StaffGh"),
            EZMC: $("#op_sszl2").val(),
            QKDJ: $("#op_yhdj").val(),
            MZFS: $("#op_mzfs").val(),
            MZFSMS: $("#op_mzfs option:selected").text(),
            MZYS: $("#op_mzys").attr("data-StaffGh"),
            MZYSMC: $("#op_mzys").val(),
            QKYHLB: $("#op_yhlb").val(),
            QKYHDJ: $("#op_yhdj option:selected").text() + "/" + $("#op_yhlb option:selected").text()
        };
    }
    $(function () {
        $(".dv-left").toggle();
        $("#sscz").click(function () {
            $(".dv-left").toggle();
        });


        $("#btn_submit_op").click(function () {
            debugger
            getopdata();
            if (!!!opdata.SSJCZBM) {
                $.modalAlert("请选择手术项目", 'error');
                return false;
            }
            if (!!!opdata.SZ) {
                $.modalAlert("请选择主刀医生", 'error');
                return false;
            }
            if (!!!opdata.SSJCZRQ) {
                $.modalAlert("请选择手术日期", 'error');
                return false;
            }
            if (opdata.QKYHDJ.indexOf("请选择")>-1) {
                opdata.QKYHDJ = "";
            }
            if (opdata.SSJCZBM != null && opdata.SSJCZBM != undefined && opdata.SSJCZBM != "") {
                var $grid = $("#gridopList");
                var gridids = $grid.jqGrid('getDataIDs');
                //在行号序列中获取最大的编号
                var maxRowId = 0;
                if (gridids.length>0) {
                    maxRowId = Math.max.apply(Math, $grid.jqGrid('getDataIDs'));
                }

                var rowid = $("#op_rowid").val(); //是否属于修改诊断
                if (rowid != null && rowid != undefined && rowid != "" && parseInt(rowid) > 0) {
                    var rowdata = $grid.jqGrid("getRowData", rowid);
                    if (opdata.SSJCZBM == rowdata.SSJCZBM) {
                        $grid.jqGrid("setRowData", rowid, opdata);
                        $.modalAlert("录入成功", 'success');

                        return true;
                    }
                }

                //debugger
                var result = checkSSdm(opdata);
                if (result) {
                    $grid.jqGrid("addRowData", maxRowId + 1, opdata);
                    $("#op_rowid").val(maxRowId + 1);
                }
                else {
                    $.modalAlert("手术已录入", 'error');
                }

            }
            else {
                $.modalAlert("请选择手术", 'warning');
            }

        });

        $("#btn_del_op").click(function () {
            var rowid = $("#op_rowid").val();
            if (rowid != null && rowid != undefined && rowid != "" && parseInt($("#op_rowid").val()) > 0) {
                //getopdata();
                opdata.zt = 0;
                opdata.ztsm = '作废';
                jQuery("#gridopList").jqGrid("setRowData", rowid, opdata);
                $.modalAlert("作废成功", 'success');
            }
            else {
                $.modalAlert("请选择手术记录", 'warning');
            }
        });

        $("#btn_reset_op").click(function () {
            jQuery("#gridopList").jqGrid().trigger('reloadGrid');
        });

    });



    //$(function () {
    //    $("#tb_opedit").css("height","350px");
    //});

    $("#op_ssdm").opFloatingSelector({
        width: 600,
        itemdbclickhandler: function ($this) {
            $("#op_ssdm").val($this.attr('data-ssmc')).attr("attr-ssdm", $this.attr('data-ssdm')).attr("attr-ssjb", $this.attr('data-ssjb'));
        }
    });

    $("#op_zdys").dutyStaffFloatingSelector({
        dutyCode: 'Doctor'
    });
    $("#op_mzys").dutyStaffFloatingSelector({
        dutyCode: 'Doctor'
    });
    $("#op_sszl1").dutyStaffFloatingSelector({
        dutyCode: 'Doctor'
    });
    $("#op_sszl2").dutyStaffFloatingSelector({
        dutyCode: 'Doctor'
    });

    $("#op_mzfs").bindSelect({
        url: "/SystemManage/Common/GetAnesList",
        id: "AnesCode",
        text:"AnesName"
    });

    $("#op_yhdj").bindSelect({
        url: "/SystemManage/Common/GetNotchGradeList",
        id: "Code",
        text: "Name"
    });

    $("#op_yhlb").bindSelect({
        url: "/SystemManage/Common/GetCommonList",
        id: "Code",
        text: "Name",
        param: { type:"QKYLB"}
    });

    function checkSSdm(data) {
        var isadd = true;
        var ids = $("#gridopList").getDataIDs();
        if (ids.length > 1) {
            $(ids).each(function (i) {
                var rows = $("#gridopList").getRowData(i + 1);
                if (rows.SSJCZBM == data.SSJCZBM) {
                    isadd = false;
                }
            })
        }
        return isadd;
    }
</script>
